package com.atguigu.minio.config;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@MapperScan(basePackages = "com.atguigu.minio.mapper")
public class MpConfig {

    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor(){
        //创建mybatis的 mp拦截器
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        //创建mp内部的自己的 分页拦截器
        PaginationInnerInterceptor paginationInnerInterceptor = new PaginationInnerInterceptor();
        paginationInnerInterceptor.setDbType(DbType.MYSQL);//设置要操作的数据库类型 默认mysql
//        paginationInnerInterceptor.setOverflow(true);//设置分页合理化：如果查询的页码超过总页码 返回最后一页

        //将分页拦截器注册给 MybatisPlusInterceptor
        interceptor.addInnerInterceptor(paginationInnerInterceptor);

        //返回MybatisPlusInterceptor注入到容器中
        return interceptor;
    }

}
